﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Activities.DAL.Model;
using Activities.DAL.Utility;



namespace Activities.DAL.DAL
{
    public class ActivitiesDal
    {
        private SqlDBHelper MVC3;
        
        
        public ActivitiesDal(string conn)
        {
            MVC3=new SqlDBHelper(conn);
        }

        public bool Delete(ActivitiesModel itemId)
        {
            string sql = "delete from Activities where Id = @Id";
            return MVC3.ExecuteNonQuery(sql, CommandType.Text, new SqlParameter[]
            {
                new SqlParameter("@Id", itemId.Id)
            });
        }

        public bool Insert(ActivitiesModel item)
        {
            string sql = @"INSERT INTO Activities (Detail,DateActivities)
                           values (@Detail,@DateActivities)";
            return  MVC3.ExecuteNonQuery(sql, CommandType.Text, new SqlParameter[]
            {
                new SqlParameter("@Detail", item.Detail),
                new SqlParameter("@DateActivities", item.DateActivities)
            });
        }

        public List<ActivitiesModel> GetItem()
        {
            string sql = @"SELECT Id,Detail,DateActivities from Activities ";
            DataTable qry = MVC3.ExecuteSelectCommand(sql, CommandType.Text);
            return Extension.ConvertTo<ActivitiesModel>(qry);
          
        }

    }
}
